package it.struts.helloworld.utils;

import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.cfg.Configuration;
import org.hibernate.service.ServiceRegistryBuilder;

public class HibernateUtils {
	
   public static Session getSessionFactory() {
        
        Configuration configuration = new Configuration();
        configuration.configure("hibernate.cfg.xml");
        ServiceRegistryBuilder serviceRegistryBuilder = new ServiceRegistryBuilder()
        	.applySettings(configuration.getProperties());
        SessionFactory sessionFactory = configuration.buildSessionFactory(
        		serviceRegistryBuilder.buildServiceRegistry());
        return sessionFactory.openSession();
    }
}
